﻿<Application
    x:Class="Croxweb.Leuphana.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:converters="clr-namespace:Croxweb.Leuphana.Converters"
    xmlns:tilt="clr-namespace:ControlTiltEffect">

    <!--Resources-->
    <Application.Resources>
        
        <!--Converters-->
        <converters:UpperCaseConverter x:Key="UpperCaseConverter" />
        <converters:StringVisibilityConverter x:Key="StringVisibilityConverter" />
        <converters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />
        <converters:BooleanVisibilityConverter x:Key="NegativeBooleanVisibilityConverter" Negative="True" />
        <converters:ListVisibilityConverter x:Key="ListVisibilityConverter" />
        
        <!--Localization-->
        <local:LocalizedResources xmlns:local="clr-namespace:Croxweb.Leuphana.Resources" x:Key="L" />

        <!--Theme-->
        <Color x:Key="PhoneContrastColor">#FFFFFFFF</Color>
        <SolidColorBrush x:Key="PhoneContrastBrush" Color="{StaticResource PhoneContrastColor}" />

        <Color x:Key="PhoneAccentColor">#FF933949</Color>
        <SolidColorBrush x:Key="PhoneAccentBrush" Color="{StaticResource PhoneAccentColor}"/>

        <Style x:Key="PhoneTextAccentStyle" TargetType="TextBlock" BasedOn="{StaticResource PhoneTextBlockBase}">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/>
        </Style>

        <!--List Buttons-->
        <Style x:Key="ListButtonStyle" TargetType="Button">
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}"/>
            <Setter Property="Padding" Value="0,0,10,20"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Background="Transparent">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver"/>
                                    <VisualState x:Name="Pressed"/>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="Left" tilt:TiltEffect.IsTiltEnabled="True"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="SpaceButtonStyle" TargetType="Button">
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}"/>
            <Setter Property="Padding" Value="{StaticResource PhoneTouchTargetOverhang}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Background="Transparent">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver"/>
                                    <VisualState x:Name="Pressed"/>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="Left" tilt:TiltEffect.IsTiltEnabled="True"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!--DataTemplate: Appointment-->
        <DataTemplate x:Key="AppointmentListTemplate">
            <StackPanel Orientation="Horizontal" Margin="0,0,0,17" tilt:TiltEffect.IsTiltEnabled="True">
                <!--Room-->
                <Canvas Height="100" Width="100" Background="{StaticResource PhoneAccentBrush}" Margin="12,0,9,0">
                    <TextBlock Text="{Binding Location}" Style="{StaticResource PhoneTextNormalStyle}" Foreground="{StaticResource PhoneContrastBrush}" />
                </Canvas>
                <!--Time/Title-->
                <StackPanel>
                    <TextBlock Text="{Binding TimeSpan}" Style="{StaticResource PhoneTextExtraLargeStyle}" />
                    <TextBlock Text="{Binding Lecture}" Margin="12,-6,12,0" Style="{StaticResource PhoneTextNormalStyle}" />
                    <TextBlock Text="{Binding Subject}" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}" />
                </StackPanel>
            </StackPanel>
        </DataTemplate>

        <!--DataTemplate: Single Appointment-->
        <DataTemplate x:Key="AppointmentSingleListTemplate">
            <StackPanel Margin="0,0,0,17" tilt:TiltEffect.IsTiltEnabled="True">
                <TextBlock Text="{Binding LongDate, Converter={StaticResource UpperCaseConverter}}" Margin="12,18"
                           Style="{StaticResource PhoneTextSubtleStyle}" Visibility="{Binding ShowDate}" />
                <TextBlock Text="{Binding TimeSpan}" Style="{StaticResource PhoneTextLargeStyle}" Visibility="{Binding ShowTime}" />
                <StackPanel>
                    <TextBlock Text="{Binding Lecture}" Margin="12,-6,12,0" Style="{StaticResource PhoneTextAccentStyle}" />
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Location}" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}" />
                        <TextBlock Text="{Binding Subject}" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}" />
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </DataTemplate>

        <!--DataTemplate: New Messages-->
        <DataTemplate x:Key="MessageNewTemplate">
            <StackPanel Margin="0,0,0,17" tilt:TiltEffect.IsTiltEnabled="True">
                <TextBlock Text="{Binding Source}" Style="{StaticResource PhoneTextLargeStyle}"/>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Sender}" Style="{StaticResource PhoneTextAccentStyle}" />
                    <TextBlock Text="{Binding ReceivedDate}" Style="{StaticResource PhoneTextAccentStyle}" />
                </StackPanel>
                <TextBlock Text="{Binding Subject}" Style="{StaticResource PhoneTextSubtleStyle}"/>
            </StackPanel>
        </DataTemplate>
        
    </Application.Resources>

    <Application.ApplicationLifetimeObjects>
        <shell:PhoneApplicationService 
            Launching="Application_Launching" Closing="Application_Closing" 
            Activated="Application_Activated" Deactivated="Application_Deactivated"/>
    </Application.ApplicationLifetimeObjects>

</Application>